<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
$(function() {
    var websocket = null;
　　 //浏览器是否支持websocket
    if ("WebSocket" in window) {
        try {
            websocket = new WebSocket("ws://192.168.199.103:54321/RFID/");
            websocket.onopen = function(data) {
                // console.log("connect success ");
            };

            websocket.onmessage = function(data) {
            	 	var received_msg = data.data;
                }
            };

            websocket.onerror = function(e) {
                // console.log('connect error ');
            };

            websocket.onclose = function(data) {
            };

            window.onbeforeunload = function() {
                websocket.close();
            }

        } catch (error) {
            // console.log('connect error ');
        }

    } else {
        // console.log("Websockets not supported");
    }

   
    
    
    $("#conn").click(function(){
    	 websocket.open();
    });

    $("#close").click(function(){
    	  if (websocket != null) {
              websocket.close();
          }
    })

});
</script>
</head>
<body>

</body>
</html>